package com.application.chiettinhdienluc.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.application.chiettinhdienluc.R;
import com.application.chiettinhdienluc.model.NguoiDungModel;

public class DanhMucNhanVienAdapter extends BaseAdapter {
	public ArrayList<NguoiDungModel> itemList;
	Animation animation = null;

	public ArrayList<NguoiDungModel> getItemList() {
		return itemList;
	}

	private Activity ac;

	public DanhMucNhanVienAdapter(Activity context, ArrayList<NguoiDungModel> countryList) {
		this.itemList = new ArrayList<NguoiDungModel>(countryList);
		ac = context;
	}

	private class ViewHolder {
		TextView tvsttValue;
		TextView tvMaNVValue;
		TextView tvTenNVValue;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;
		// View view = null;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(ac);
			convertView = inflater.inflate(R.layout.danh_muc_nhan_vien_item, null);
			holder.tvsttValue = (TextView) convertView.findViewById(R.id.tvsttValue);
			holder.tvMaNVValue = (TextView) convertView.findViewById(R.id.tvMaNVValue);
			holder.tvTenNVValue = (TextView) convertView.findViewById(R.id.tvTenNVValue);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		try {

			NguoiDungModel nguoidung = itemList.get(position);
			holder.tvsttValue.setText(position+1+"");
			holder.tvMaNVValue.setText(nguoidung.get_TenDangNhap());
			holder.tvTenNVValue.setText(nguoidung.get_TenNguoiDung());
			 animation = AnimationUtils.loadAnimation(ac, R.anim.push_up_in);
			 convertView.startAnimation(animation);
			 animation = null;

		} catch (Exception e) {
			e.printStackTrace();
		}
		return convertView;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return itemList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return itemList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public void setItemList(ArrayList<NguoiDungModel> countryList) {
		this.itemList = new ArrayList<NguoiDungModel>(countryList);
	}

}
